#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 修复相对导入问题
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from crawler.PerformanceForecastParser import PerformanceForecastParser
from crawler.AssetRestructureParser import AssetRestructureParser
from crawler.AnnualReportParser import AnnualReportParser
from loguru import logger

def main():
    # 为不同类型的新闻创建对应的解析器
    parsers = {
        '业绩预告': PerformanceForecastParser(),
        '资产重组': AssetRestructureParser(),
        '年报': AnnualReportParser()
    }
    
    for tag, parser in parsers.items():
        try:
            data = parser.get_news_list(tag, 1) or []
            logger.info(f"{tag}: {len(data)} 条")
            if data:
                item = data[0]
                logger.info(f"  示例: {item.get('title','无标题')} | {item.get('category','')} | {item.get('publish_time','')}")
        except Exception as e:
            logger.error(f"{tag} 失败: {e}")

if __name__ == '__main__':
    main()